﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Statistics.ascx.cs" Inherits="ERP.Modules.Statistic.Statistics" %>
<%-----------------------------------------------------%>
<ext:Hidden ID="FormatTypeOrder" runat="server" />
<%----------------GridOrderStatistic-----------------%>
<ext:GridPanel
    ID="grOrderStatistic"
    Border="False"
    runat="server"
    Cls="grid-double"
    EnableColumnMove="true">
    <Store>
        <%----------------StoreOrderStatistic-----------------%>
        <ext:Store
            ID="StoreOrderStatistic"
            runat="server"
            OnReadData="StoreOrderStatistic_RefreshData"
            OnSubmitData="StoreOrderStatistic_Submit"
            PageSize="10">
            <Model>
                <ext:Model ID="Model4" runat="server" IDProperty="Order_Id">
                    <Fields>
                        <ext:ModelField Name="Rows_ID" Type="Int" />
                        <ext:ModelField Name="Order_Id" Type="Int" />
                        <ext:ModelField Name="Customer_Name" Type="String" />
                        <ext:ModelField Name="Order_Code" Type="String" />
                        <ext:ModelField Name="Order_DateBegin" Type="Date" />
                        <ext:ModelField Name="Order_DateEnd" Type="Date" />
                        <ext:ModelField Name="Order_Payment_Date" Type="Date" />
                        <ext:ModelField Name="IsUsed" Type="Boolean" />
                    </Fields>
                </ext:Model>
            </Model>
        </ext:Store>
    </Store>
    <ColumnModel runat="server">
        <Columns>
            <ext:Column ID="Column1" runat="server" Text="STT" Width="35" DataIndex="Rows_ID" Align="Center"></ext:Column>
            <ext:Column ID="Column2" runat="server" Text="ID" Width="15" DataIndex="Order_Id" Visible="false"></ext:Column>
            <ext:Column ID="Column3" runat="server" Text="Người đặt hàng" Width="200" DataIndex="Customer_Name"></ext:Column>
            <ext:Column ID="Column4" runat="server" Text="Chứng từ đặt" Width="100" DataIndex="Order_Code" Align="Left"></ext:Column>
            <ext:DateColumn ID="DateColumn1" runat="server" Text="Ngày đặt" Width="100" DataIndex="Order_DateBegin" Format="dd-MM-yyyy" Align="Right" Flex="1"></ext:DateColumn>
            <ext:DateColumn ID="DateColumn2" runat="server" Text="Ngày giao" Width="100" DataIndex="Order_DateEnd" Format="dd-MM-yyyy" Align="Right" Flex="1"></ext:DateColumn>
            <ext:DateColumn ID="DateColumn3" runat="server" Text="Hạn thanh toán" Width="100" DataIndex="Order_Payment_Date" Format="dd-MM-yyyy" Align="Right" Flex="1"></ext:DateColumn>
            <ext:CheckColumn ID="Checked" runat="server" Text="Trạng thái" Width="75" DataIndex="IsUsed" Align="Center"></ext:CheckColumn>
        </Columns>
    </ColumnModel>
    <DirectEvents>
        <ItemDblClick OnEvent="DbClick_db">
            <ExtraParams>
                <ext:Parameter Name="Order_Id" Value="record.data.Order_Id" Mode="Raw"></ext:Parameter>
            </ExtraParams>
            <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
        </ItemDblClick>
    </DirectEvents>
    <SelectionModel>
        <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" Mode="Multi">
        </ext:CheckboxSelectionModel>
    </SelectionModel>
    <DockedItems>
        <ext:Toolbar ID="ToolbarTopStatistic" runat="server" Dock="Top">
            <Items>
                <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete" ToolTip="Check vào một hoặc nhiều phiếu đề nghị để xoá">
                    <DirectEvents>
                        <Click OnEvent="btnDel_Click">
                            <EventMask ShowMask="true" Msg="Đang tải..." />
                            <ExtraParams>
                                <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                            </ExtraParams>
                            <Confirmation ConfirmRequest="true"
                                Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                            </Confirmation>
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:ToolbarSeparator />
                <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                    <Menu>
                        <ext:Menu ID="MenuMain" runat="server">
                            <Items>
                                <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                    <Listeners>
                                        <Click Handler="submitValue(#{grOrderStatistic}, #{FormatTypeOrder}, 'xml');" />
                                    </Listeners>
                                </ext:MenuItem>
                                <ext:MenuSeparator ID="MenuSeparator1" runat="server" />
                                <ext:MenuItem ID="MenuItemExPortExcel" runat="server" Text="Excel" Icon="PageExcel">
                                    <Listeners>
                                        <Click Handler="submitValue(#{grOrderStatistic}, #{FormatTypeOrder}, 'xls');" />
                                    </Listeners>
                                </ext:MenuItem>
                                <ext:MenuSeparator ID="MenuSeparator2" runat="server" />
                                <ext:MenuItem ID="MenuItemExportCSV" runat="server" Text="CSV" Icon="PageAttach">
                                    <Listeners>
                                        <Click Handler="submitValue(#{grOrderStatistic}, #{FormatTypeOrder}, 'xls');" />
                                    </Listeners>
                                </ext:MenuItem>
                            </Items>
                        </ext:Menu>
                    </Menu>
                </ext:Button>
            </Items>
        </ext:Toolbar>
        <ext:Toolbar ID="ToolbarBottomStatistic" runat="server" Dock="Bottom" AnchorHorizontal="100%">
            <Items>
                <ext:TriggerField ID="txtSearch_Statistic" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                    <Triggers>
                        <ext:FieldTrigger Icon="Search" />
                    </Triggers>
                    <DirectEvents>
                        <TriggerClick OnEvent="Search_Event"></TriggerClick>
                        <KeyPress OnEvent="Search_Event"></KeyPress>
                        <KeyUp OnEvent="Search_Event"></KeyUp>
                    </DirectEvents>
                </ext:TriggerField>
                <ext:PagingToolbar ID="PagingToolbarStatistic" runat="server" StoreID="StoreOrderStatistic" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
            </Items>
        </ext:Toolbar>
    </DockedItems>
</ext:GridPanel>
<%----------------WindowsOrderReview-----------------%>
<ext:Window ID="WindowOrderDetail" runat="server"
    Title="Chi tiết đơn mua hàng"
    DefaultAnchor="100%"
    Width="1000"
    Dock="Top"
    Height="605"
    Hidden="true"
    AutoScroll="False"
    Maximizable="true"
    Minimizable="False"
    AutoDataBind="true"
    Region="Center"
    Resizable="true"
    Modal="true"
    Layout="AnchorLayout"
    HideMode="Offsets">
    <Content>
        <ext:Panel ID="PanelToolbarDetail"
            runat="server"
            Cls="width"
            Layout="Fit"
            Dock="Top"
            ButtonAlign="Left"
            AutoScroll="true">
            <DockedItems>
                <ext:Toolbar ID="ToolbarDetail" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnPrintReviewOrder" runat="server" Text="In đơn mua hàng" Icon="Printer" ToolTip="In đơn mua hàng" OnClientClick="window.print();"></ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExitReviewOrder" runat="server" Text="Đóng lại" Icon="Cancel" ToolTip="Đóng cửa sổ xét duyệt">
                            <DirectEvents>
                                <Click OnEvent="btnExitDetailOrder_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:Panel>
        <ext:FormPanel ID="FormPanelDetail"
            runat="server"
            Border="false"
            Frame="true"
            AnchorHorizontal="100%"
            AnchorVertical="100%"
            DefaultAnchor="100%">
            <Items>
                <ext:FieldSet ID="FieldSetDetailInfo"
                    runat="server"
                    Title="Thông tin khách hàng"
                    MarginSpec="0 8 0 0"
                    Padding="10"
                    AnchorHorizontal="100%"
                    ButtonAlign="Right">
                    <Defaults>
                        <ext:Parameter Name="Width" Value="500" />
                        <ext:Parameter Name="LabelWidth" Value="90" />
                    </Defaults>
                    <Items>
                        <ext:Container runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label1" runat="server" Text="Mã khách hàng:" MarginSpec="0 8 15 0"></ext:Label>
                                <ext:Label ID="lbReviewCustomer_Alias" Cls="x-label-right" runat="server" Text=""></ext:Label>

                            </Items>
                        </ext:Container>

                        <ext:Container runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label2" runat="server" Text="Tên khách hàng:" MarginSpec="0 8 15 0"></ext:Label>
                                <ext:Label ID="lbReviewCustomer_Name" Cls="x-label-right" runat="server" Text=""></ext:Label>
                            </Items>
                        </ext:Container>

                        <ext:Container runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label3" runat="server" Text="Chứng từ đặt:" MarginSpec="0 8 15 0"></ext:Label>
                                <ext:Label ID="lbReviewOrderCode" Cls="x-label-right" runat="server" Text=""></ext:Label>
                            </Items>
                        </ext:Container>

                        <ext:Container runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label4" runat="server" Text="Ngày đặt hàng:" MarginSpec="0 8 15 0"></ext:Label>
                                <ext:Label ID="lbReviewOrderDate" Cls="x-label-right" runat="server" Text=""></ext:Label>
                            </Items>
                        </ext:Container>

                        <ext:Container runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label5" runat="server" Text="Ngày duyệt/huỷ:" MarginSpec="0 8 15 0"></ext:Label>
                                <ext:Label ID="lbReviewDateUpdate" Cls="x-label-right" runat="server" Text=""></ext:Label>
                            </Items>
                        </ext:Container>

                        <ext:Container runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label6" runat="server" Text="Thời gian duyệt/huỷ vào lúc:" MarginSpec="0 8 15 0"></ext:Label>
                                <ext:Label ID="lbReViewTime" Cls="x-label-right" runat="server" Text=""></ext:Label>
                            </Items>
                        </ext:Container>
                    </Items>
                </ext:FieldSet>
                <ext:FieldSet ID="FieldSetDetailInfoMaterial"
                    runat="server"
                    Title="Thông tin vật tư"
                    MarginSpec="0 8 0 0"
                    Padding="10"
                    AnchorHorizontal="100%"
                    ButtonAlign="Right">
                    <Items>
                        <ext:GridPanel
                            ID="grOrderDetail"
                            Border="True"
                            runat="server"
                            AutoWidth="true"
                            AutoScroll="true"
                            Cls="gird"
                            Layout="Fit"
                            EnableColumnMove="true"
                            Height="240">
                            <Store>
                                <%-------------StoreOrderDetail----------------%>
                                <ext:Store
                                    ID="StoreOrderDetail"
                                    runat="server"
                                    OnReadData="StoreOrderDetail_RefreshData"
                                    PageSize="10">
                                    <Model>
                                        <ext:Model ID="Model6" runat="server" IDProperty="Order_Detail_Id">
                                            <Fields>
                                                <ext:ModelField Name="Rows_ID" Type="Int" />
                                                <ext:ModelField Name="Order_Id" Type="Int" />
                                                <ext:ModelField Name="Materials_Id" Type="Int" />
                                                <ext:ModelField Name="Materials_Name" Type="String" />
                                                <ext:ModelField Name="Order_Detail_Quality" Type="Int" />
                                                <ext:ModelField Name="Order_Detail_Price" Type="Float" />
                                                <ext:ModelField Name="Order_Detail_CK_Percent" Type="Float" />
                                                <ext:ModelField Name="Order_Detail_CK" Type="Float" />
                                                <ext:ModelField Name="Order_Detail_VAT_Percent" Type="Float" />
                                                <ext:ModelField Name="Order_Detail_VAT" Type="Float" />
                                                <ext:ModelField Name="Order_Detail_Total_Price" Type="Float" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel runat="server">
                                <Columns>
                                    <ext:Column ID="Column32" runat="server" Text="STT" Width="35" DataIndex="Rows_ID" Align="Center"></ext:Column>
                                    <ext:Column ID="Column33" runat="server" Text="ID" Width="15" DataIndex="Order_Id" Visible="false"></ext:Column>
                                    <ext:Column ID="Column34" runat="server" Text="ID Vật Tư" Width="15" Visible="false" DataIndex="Materials_Id"></ext:Column>
                                    <ext:Column ID="Column35" runat="server" Text="Tên vật tư" Width="100" DataIndex="Materials_Name" Align="Left"></ext:Column>
                                    <ext:Column ID="Column36" runat="server" Text="Số lượng" Width="50" DataIndex="Order_Detail_Quality" Align="Center"></ext:Column>
                                    <ext:NumberColumn ID="NumberColumn9" runat="server" Text="Đơn giá" Width="75" DataIndex="Order_Detail_Price" Format="0,00" Align="Center"></ext:NumberColumn>
                                    <ext:Column ID="Column37" runat="server" Text="% CK" Width="50" DataIndex="Order_Detail_CK_Percent" Align="Center">
                                        <Renderer Fn="pctChange" />
                                    </ext:Column>
                                    <ext:NumberColumn ID="NumberColumn10" runat="server" Text="Tiền CK" Width="75" DataIndex="Order_Detail_CK" Format="0,00" Align="Center"></ext:NumberColumn>
                                    <ext:Column ID="Column38" runat="server" Text="% VAT" Width="50" DataIndex="Order_Detail_VAT_Percent" Align="Center">
                                        <Renderer Fn="pctChange" />
                                    </ext:Column>
                                    <ext:NumberColumn ID="NumberColumn11" runat="server" Text="Tiền VAT" Width="75" DataIndex="Order_Detail_VAT" Format="0,00" Align="Center"></ext:NumberColumn>
                                    <ext:NumberColumn ID="NumberColumn12" runat="server" Text="Tổng tiền" Width="75" Flex="1" DataIndex="Order_Detail_Total_Price" Format="0,00" Align="Center" CustomSummaryType="totalCost"></ext:NumberColumn>
                                </Columns>
                            </ColumnModel>
                            <BottomBar>
                                <ext:PagingToolbar ID="PagingToolbarDetail" runat="server" StoreID="StoreOrderDetail" EmptyMsg="Không có dữ liệu" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </BottomBar>
                        </ext:GridPanel>
                        <ext:Hidden ID="HdReviewOrder_Id" runat="server"></ext:Hidden>
                        <ext:Hidden ID="HdReviewIsActive" runat="server"></ext:Hidden>
                    </Items>
                </ext:FieldSet>
                <ext:FieldSet ID="FieldSetReViewTotal"
                    runat="server"
                    Title="Tổng tiền các mặt hàng"
                    MarginSpec="0 8 0 0"
                    Padding="10"
                    AnchorHorizontal="100%"
                    ButtonAlign="Right">
                    <Items>
                        <ext:Container ID="Container7" runat="server" Layout="HBoxLayout">
                            <Items>
                                <ext:Label ID="Label7" runat="server" Text="Tổng tiền các mặt hàng:" MarginSpec="0 8 8 0"></ext:Label>
                                <ext:Label ID="lbTotalMaterialReview" Cls="x-label-right-cost" runat="server" Text=""></ext:Label>
                            </Items>
                        </ext:Container>
                    </Items>
                </ext:FieldSet>
            </Items>
        </ext:FormPanel>
    </Content>
</ext:Window>
